<template>
  <div class="detail-page">
    <div class="page-header">
      <div class="title-box">
        <el-button class="back-button" icon="el-icon-back" @click="goback">返回</el-button>
        <div class="page-title">文章详情</div>
      </div>
      <div>
        <el-button type="primary" class="back-button" @click="detailToEdit">编辑</el-button>
      </div>
    </div>
    <div class="page-body">
      <div class="page-left">
        <el-descriptions :column="1" border size="medium">
          <el-descriptions-item label="文章名称">{{ form.title }}</el-descriptions-item>
          <el-descriptions-item label="所在分类">{{ form.type }}</el-descriptions-item>
          <el-descriptions-item label="可见范围">{{ form.affiliationId }}</el-descriptions-item>
          <el-descriptions-item label="分类排序">{{ form.sort }}</el-descriptions-item>
          <el-descriptions-item label="发布状态">{{ releaseList[form.status] }}</el-descriptions-item>
        </el-descriptions>
      </div>
      <div class="page-right">
        <v-md-preview :text="form.content" height="100%" mode="preview" left-toolbar="" right-toolbar="" />
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      form: {},
      releaseList: ['草稿', '未发布', '已发布']
    }
  },
  methods: {
    init (row) {
      this.form = { ...row }
    },
    goback () {
      this.$emit('goback')
    },
    detailToEdit () {
      this.$emit('detailToEdit', this.form)
    }
  }
}
</script>
<style scoped lang="scss">
  .page-header {
    display: flex;
    height: 60px;
    align-items: center;
    border-bottom: 1px solid #ddd;
    justify-content: space-between;
    .title-box {
      display: flex;
      height: 60px;
      align-items: center;
    }
    .back-button {
      margin-right: 16px;
    }
    .page-title {
      font-size: 18px;
      font-weight: 600;
    }
  }
  .page-body {
    height: calc(100vh - 130px);
    overflow-y: auto;
    display: flex;
    .page-left {
      padding-top:16px;
      width: 450px;
    }
    .page-right {
      flex: 1;
      margin-left: 16px;
    }
  }
</style>
